import Vue from 'vue'
import App from './App'

import ajax from "./ajax/ajax.js";
// 引入vuex 状态库
import store from "./store";
// 在main.js中注册全局组件
import toast from './components/toast/toast.vue'
Vue.component('toast',toast)

Vue.config.productionTip = false
Vue.prototype.$ajax = ajax;
Vue.prototype.$store = store;


function alert(msg,icon){
 
	if(!msg){
		return
	}
	
	if(icon){
		uni.showToast({
			title:msg,
			icon:icon
		})
	}else{
		uni.showToast({
			title:msg,
			icon:"none"
		})
	}
	
}
function loading(tf){
	if(tf){
		 
		store.commit("switch_loading",tf)
	}else{
		store.commit("switch_loading")

	}
}
Vue.prototype.$alert = alert;
Vue.prototype.$loading = loading;
App.mpType = 'app'

const app = new Vue({
	store,
    ...App
})
app.$mount()
